import { GBox } from "../../../../com/mui/containers/GBox";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { Language } from "../../../../extend/language/Language";
import { ObjectPool } from "../../../../com/gengine/utils/pools/ObjectPool";
import { LoginNoticeItem } from "./LoginNoticeItem";
type int = number;
//class LoginNoticeBody
    
    export  class LoginNoticeBody extends GBox
    {
        constructor()
        {
            super();
            this._bg = new Object /* flash.display.Shape */();
            addChild(this._bg);
            return;
        }

        public addList(arg1: Array<any>): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            if (arg1.length > 0) 
            {
                if (!this._addTitle) 
                {
                    this._addTitle = new Object /* flash.text.TextField */();
                    this._addTitle.autoSize = flash.text.TextFieldAutoSize.LEFT;
                    this._addTitle.mouseEnabled = false;
                    this._addTitle.filters = [FilterConst.glowFilter];
                    this._addTitle.width = 70;
                    this._addTitle.height = 20;
                    this._addTitle.textColor = 16754688;
                    this._addTitle.text = Language.getString(20620) + "：";
                }
                addChild(this._addTitle);
                loc2 = arg1.length;
                while (loc1 < loc2) 
                {
                    loc4 = arg1[loc1];
                    (loc3 = ObjectPool.getObject(LoginNoticeItem)).updateData(loc4);
                    addChild(loc3);
                    ++loc1;
                }
                loc5 = this.getItemBoxPos(0);
                loc1 = 0;
                loc2 = numChildren;
                while (loc1 < loc2) 
                {
                    if ((loc3 = getChildAt(loc1) as LoginNoticeItem) && loc3.type == 0 && loc3.hasItemBox()) 
                    {
                        loc3.updateBoxPos(loc5);
                    }
                    ++loc1;
                }
            }
            return;
        }

        public updateList(arg1: Array<any>): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            if (arg1.length > 0) 
            {
                if (!this._updateTitle) 
                {
                    this._updateTitle = new Object /* flash.text.TextField */();
                    this._updateTitle.autoSize = flash.text.TextFieldAutoSize.LEFT;
                    this._updateTitle.mouseEnabled = false;
                    this._updateTitle.filters = [FilterConst.glowFilter];
                    this._updateTitle.height = 20;
                    this._updateTitle.width = 70;
                    this._updateTitle.textColor = 16754688;
                    this._updateTitle.text = Language.getString(20621) + "：";
                }
                addChild(this._updateTitle);
                loc2 = arg1.length;
                while (loc1 < loc2) 
                {
                    loc4 = arg1[loc1];
                    (loc3 = ObjectPool.getObject(LoginNoticeItem)).updateData(loc4);
                    addChild(loc3);
                    ++loc1;
                }
                loc5 = this.getItemBoxPos(1);
                loc1 = 0;
                loc2 = numChildren;
                while (loc1 < loc2) 
                {
                    if ((loc3 = getChildAt(loc1) as LoginNoticeItem) && loc3.type == 1 && loc3.hasItemBox()) 
                    {
                        loc3.updateBoxPos(loc5);
                    }
                    ++loc1;
                }
            }
            return;
        }

        public getItemBoxPos(arg1: int): int
        {
            var loc1=0;
            var loc3=null;
            var loc4=0;
            var loc5=0;
            var loc2=numChildren;
            while (loc1 < loc2) 
            {
                if ((loc3 = getChildAt(loc1) as LoginNoticeItem) && loc3.type == arg1 && loc3.hasItemBox()) 
                {
                    if ((loc5 = loc3.textWidth) > loc4) 
                    {
                        loc4 = loc5;
                    }
                }
                ++loc1;
            }
            return loc4;
        }

        public clearVersion(): void
        {
            var loc1=null;
            var loc2=(numChildren - 1);
            while (loc2 >= 0) 
            {
                loc1 = getChildAt(loc2);
                if (loc1 is flash.display.Shape) 
                {
                    --loc2;
                    continue;
                }
                else 
                {
                    if (typeof loc1 === "loginnoticeitem") 
                    {
                        (loc1 as LoginNoticeItem).dispose();
                        ObjectPool.disposeObject(loc1);
                    }
                    removeChild(loc1);
                }
                --loc2;
            }
            return;
        }

        protected get maxWidth(): int
        {
            var loc1=0;
            var loc3=null;
            var loc4=0;
            var loc5=0;
            var loc2=numChildren;
            while (loc1 < loc2) 
            {
                loc3 = getChildAt(loc1) as LoginNoticeItem;
                if (loc3) 
                {
                    if ((loc5 = loc3.width) > loc4) 
                    {
                        loc4 = loc5;
                    }
                }
                ++loc1;
            }
            return loc4;
        }

        public updatePox(arg1: int): void
        {
            this._px = arg1;
            if (this._px > 80) 
            {
                this._px = this._px - 40;
            }
            this.resetPosition();
            return;
        }

        public updateBgSize(): void
        {
            this._bg.graphics.beginFill(0, 0);
            this._bg.graphics.drawRect(0, 0, 667, this.height);
            this._bg.graphics.endFill();
            return;
        }

        protected /* override */ resetPosition(): void
        {
            var loc1=0;
            var loc4=null;
            var loc2=0;
            var loc3=this.numChildren;
            loc1 = 0;
            while (loc1 < loc3) 
            {
                if (!((loc4 = this.getChildAt(loc1)) is flash.display.Shape)) 
                {
                    loc4.x = this._px;
                    loc4.y = loc2 + verticalGap;
                    if (loc4 is flash.text.TextField) 
                    {
                        if (loc1 != 0) 
                        {
                            loc4.y = loc4.y + 20;
                        }
                    }
                    loc2 = loc4.y + loc4.height;
                }
                ++loc1;
            }
            return;
        }

        public /* override */ get width(): number
        {
            var loc1=0;
            if (this._addTitle && contains(this._addTitle) || this._updateTitle && contains(this._updateTitle)) 
            {
                loc1 = 60;
            }
            loc1 = loc1 + this.maxWidth;
            return loc1;
        }

        public /* override */ get height(): number
        {
            var loc1=0;
            var loc3=0;
            var loc4=null;
            var loc2=numChildren;
            while (loc1 < loc2) 
            {
                if ((loc4 = getChildAt(loc1)) is flash.display.Shape) 
                {
                    ++loc1;
                    continue;
                }
                loc3 = loc3 + (loc4.height + this.verticalGap);
                ++loc1;
            }
            if (this._updateTitle && contains(this._updateTitle)) 
            {
                loc3 = loc3 + 60;
            }
            return loc3;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Shape */;

        /* internal */ /* var */_addTitle: Object /* flash.text.TextField */;

        /* internal */ /* var */_updateTitle: Object /* flash.text.TextField */;

        /* internal */ /* var */_px: int=80;
    }
